type ProjectErr = {
  500: (msg: string) => void
}

// 请求失败后统一错误处理
const serverErr: () => void = () => {
  uni.showToast({
    title: '请求超时，请重试！',
    duration: 2000,
    icon: 'none',
  })
}

const projectErr: ProjectErr = {
  500(msg: string) {
    if (msg) {
      uni.showToast({
        title: msg,
        duration: 2000,
        icon: 'none',
      })
    } else {
      uni.showToast({
        title: '请求异常，请联系管理员',
        duration: 2000,
        icon: 'none',
      })
    }
  },
}

export { serverErr, projectErr }
